package routers

import (
	"blog/controllers"
	controllers2 "blog/controllers/api"
	"github.com/astaxie/beego"
)

func init() {

	beego.Router("/portfolio/index/:id", &controllers.PortfolioController{}, "*:Index")
	beego.Router("/", &controllers.ArticleController{}, "*:Index")
	beego.Router("/article/:id", &controllers.ArticleController{}, "*:GetOne")
	beego.Router("/contact/index", &controllers.ContactController{}, "*:Index")

	ns :=
		beego.NewNamespace("/api",
			beego.NSRouter("/login", &controllers2.LoginController{}, "post:Login"),
			beego.NSRouter("/logout", &controllers2.LoginController{}, "get:Logout"),

			beego.NSRouter("/admin/edit/:id", &controllers2.AdminController{}, "get:GetOne"),
			beego.NSRouter("/admin/update/:id", &controllers2.AdminController{}, "Post:Put"),
		)
	//注册 namespace
	beego.AddNamespace(ns)

}
